package codegen.client.mapper;

import java.lang.reflect.Field;

import uk.co.q3c.deplan.server.util.ReflectionFieldType;
import codegen.builders.CodegenMethod;

public class ReflectionFieldDescriptor {
	public ReflectionFieldType type;
	public Field field;
	public String name;
	public WidgetDef widgetDef;
	// public Class<? extends Widget> widgetType;
	public Class<?> clazz;
	// // type for a generified collection
	public Class<?> genericType;
	// public Class<?> genericClass;
	public String getter;
	public String setter;
	public String format;
	public String widgetName;
	public String labelName;
	public String labelText;
	public CodegenMethod widgetGetDataValueMethod;
	public CodegenMethod widgetSetDataValueMethod;
	public CodegenMethod viewSetLabelTextMethod;
	public CodegenMethod domainSetValueMethod;
	public CodegenMethod domainGetValueMethod;
	public CodegenMethod viewGetWidgetDataValueMethod;
	public CodegenMethod viewSetWidgetDataValueMethod;
	public boolean isCalculated;

	public Object getFieldValue(Object target) throws IllegalArgumentException, IllegalAccessException {
		field.setAccessible(true);
		return field.get(target);
	}

	public boolean selfLabelling() {
		return widgetDef.isSelfLabel();
	}

}
